package cheme.Interpreter.AST.Arithmetic;

import cheme.Interpreter.AST.Interfaces.IAstExpression;

public class AstNegation extends AstUnarayOpAstNode
{
	public AstNegation()
	{
		super();
	}
	
	public AstNegation(IAstExpression operand)
	{
		super(operand);
	}
	
	public double evaluate()
	{
		assert null != getOperand();
		
		double result = 0.0;
		
		if(null != getOperand())
		{
			result = -(getOperand().evaluate());
		}
		
		return result;
	}
	
	@Override
	public String toString()
	{
		assert null != getOperand();
		
		String result = "0.0";
		
	
		if(null != getOperand())
		{
			result = "-(" + getOperand().toString() + ")";
		}
		
		return result;
	}
}
